# encoding=utf-8
from entity.entity import category
import html, uuid
import json


# 对象变成字典
def obj2dir(obj):
    return obj.__dict__


# 字典变成对象
def dir2obj(dir, obj):
    d = obj()
    for k, v in dir.items():
        d[k] = v
    return d


# Unicode转中文 &#160;&#160;
def decodeHtml2Chinese(input):
    s = html.unescape(input)
    return s


def getUuid():
    return str(uuid.uuid4()).replace("-", "")


def dir2str(dir):
    return str(dir)


def str2dir(str):
    return eval(str)

# c = "<br> &#160;&#160;&#160;&#160;&#36825;&#23601;&#24456;&#38590;&#21463;&#20102;&#12290;"
# print(decodeHtml(c))

# c = category()
# c.name = '是是是'
# c.catrgory = 'sss'
# c.uri = 'assssssssssssssss'
# print(c)
# obj_dir = obj2dir(c)
# print(obj_dir)
# c = {'name': '是', 'uri': 'S', 'category': 'd'}
# print(dir2obj(c, category))
# a = '{"a":"1", "b":"1"}'
# b = eval(a)
# print(b, type(b))
#
